using System;
using Bordecal.ImportsSorter.Properties;

namespace Bordecal.ImportsSorter
{
	internal struct Range<T> where T : struct, IComparable<T>
	{
		#region Fields

		private readonly T minimum;
		private readonly T maximum;

		#endregion

		#region Constructors
		
		internal Range(T minimum, T maximum)
		{
			if (minimum.CompareTo(maximum) > 0) throw new ArgumentException(Resources.ArgEx_RangeMinGreaterThanMax, "minimum");

			this.minimum = minimum;
			this.maximum = maximum;
		}

		#endregion

		#region Properties

		internal T Minimum
		{
			get
			{
				return this.minimum;
			}
		}

		internal T Maximum
		{
			get
			{
				return this.maximum;
			}
		}

		#endregion

		#region Methods

		internal bool IsInRange(T testValue)
		{
			bool retVal = false;

			if (testValue.CompareTo(this.Minimum) >= 0)
			{
				if (testValue.CompareTo(this.Maximum) <= 0)
				{
					retVal = true;
				}
			}

			return retVal;
		}

		#endregion
	}
}